<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

//模版的使用
Route::get('/', ['uses'=>'UserController@index']);

//增删该查详解
Route::any('cudr/{id?}', ['uses'=>'UserController@cudr'])->where(['id'=>'[0-9]+']);

Route::any('url', ['as' => 'url', 'uses'=>'UserController@testUrl']);

//数据请求试例
Route::any('request1', ['uses'=>'UserController@request1']);


/**
 * 中间建，过滤进入应用场景的http请求
 * 应用场景  有一个活动，在指定日期后开始，如果活动没有开始,只能访问宣传页面
 */
Route::any('activity1', ['as'=>'activity1','uses'=>'UserController@activity1']);   //宣传页面
Route::group(['middleware' => ['activity']], function () {
    Route::any('activity2', ['uses'=>'UserController@activity2']);   //活动1页面
    Route::any('activity3', ['uses'=>'UserController@activity3']);  //活动2页面
});




/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

/**
 * session的使用
 */
Route::group(['middleware' => ['web']], function () {
    Route::any('session1', ['uses'=>'UserController@session1']);
    Route::any('session2', ['as'=> 's2', 'uses'=>'UserController@session2']);
    Route::any('response', ['uses'=>'UserController@response']);


    /**
     * （小项目）数据的增删该查
     */
    Route::get('member/index', ['uses'=>'TestController@index']);   //首页
    Route::any('member/add', ['uses'=>'TestController@add']);
    Route::any('member/delete/{id?}', ['as'=>'del_member','uses'=>'TestController@delete'])->where('id','[0-9]+');

});
